package org.gushi.datastruct.a06;

public class Person implements Comparable<Person>{

    public Person(int age){
        this.age = age;
    }

    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //通过这里对比 有点问题  不灵活  不能随意变化
    @Override
    public int compareTo(Person person) {
        if(this.age>person.getAge()){
            return 1;
        }else if(this.age<person.getAge()){
            return -1;
        }
        return 0;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }
}
